package com.SSH_Test.dao;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;

import com.SSH_Test.pojo.User;

@Component("userdao")
public class Userdao {

	private SessionFactory  sessionFactory;
	
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	@Resource(name="mySessionFactory")
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	public List<User> listUser(){
		List<User> list ;
		Session session=sessionFactory.openSession();
		session.beginTransaction();
		list = session.createQuery("from User").list();
		return list;
	}
}
